fixed problems shown by tests/model.c
authorØyvind Kolås <ok@src.gnome.org>
Tue, 30 Aug 2005 12:49:55 +0000 (12:49 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Tue, 30 Aug 2005 12:49:55 +0000 (12:49 +0000)
ChangeLog
babl/base/model-gray.c
extensions/Makefile.in
extensions/naive-CMYK.c

index 9c5df2296525a64e2030db902d43765bc0c11671..aeb9fd2aefa1eda95cc900921a704fc21745f6e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-08-30  Øyvind Kolås  <pippin@gimp.org>
+
+       * babl/base/model-gray.c: 
+               (rgba_to_gray_alpha_premultiplied): fixed array index error.
+       * extensions/Makefile.in: Added -I../babl to include path.
+       * extensions/naive-CMYK.c: (init), (rgb_to_cmyk), (cmyk_to_rgb):
+               reordered the code, fixed a component swapping issue
+               discovered by tests/model.c
+
 2005-08-30  Øyvind Kolås  <pippin@gimp.org>
 
        * tests/srgb_to_lab_u8.c: updated values.
index d8097bd04a2a804dc46895272ff314a54f687afd..b494dea9930194b0f0e179fae4917db08d3a6f37 100644 (file)
@@ -255,7 +255,7 @@ gray_alpha_premultiplied_to_rgba (int    src_bands,
       double luminance = *(double *)src[0];
       double alpha     = *(double *)src[1];
 
-      if (alpha > 0.001)
+      if (alpha > 0.00001)
         {
           luminance = luminance / alpha;
         }
@@ -301,7 +301,7 @@ rgba_to_gray_alpha_premultiplied (int    src_bands,
       luminance *= alpha;
       
       *(double*)dst[0] = luminance;
-      *(double*)dst[2] = alpha;
+      *(double*)dst[1] = alpha;
       BABL_PLANAR_STEP
     }
 }
index 40c798f0db40ad47d0d51377511737aea4924e5a..cb4bb42380f1b0a102fc75f7f96bf584ff3b1714 100644 (file)
@@ -6,7 +6,6 @@ SOBJS   = $(CFILES:.c=.so)
 all: $(SOBJS)
 
 
-
 %.so: %.c
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
 
@@ -21,13 +20,13 @@ CIE-Lab.so: CIE-Lab.c
 
 
 
-
 #############################################################################
 #############################################################################
 CFLAGS  = -O2 -Wall
 LDFLAGS = -shared -lc
 
-CFLAGS  += `pkg-config babl --cflags`
+CFLAGS  += -I../babl
+#`pkg-config babl --cflags`
 #LDFLAGS += `pkg-config babl --libs`
 
 
index b69ce385a997a861305738a5ad74ec7c1be45b16..2eb39e61a90f352cfa7acf5779d989fe9fbbcde7 100644 (file)
 #include "babl.h"
 #include "util.h"
 
-static void components    (void);
-static void models        (void);
-static void conversions   (void);
-static void formats       (void);
-
+static void rgb_to_cmyk (int    src_bands,
+                         void **src,
+                         int   *src_pitch,
+                         int    dst_bands,
+                         void **dst,
+                         int   *dst_pitch,
+                         int    n);
+static void cmyk_to_rgb (int    src_bands,
+                         void **src,
+                         int   *src_pitch,
+                         int    dst_bands,
+                         void **dst,
+                         int   *dst_pitch,
+                         int    n);
 int
 init (void)
 {
-  components    ();
-  models        ();
-  conversions   ();
-  formats       ();
-
-  return 0;
-}
 
-static void
-components (void)
-{
   babl_component_new ("cyan",    NULL);
   babl_component_new ("yellow",  NULL);
   babl_component_new ("magenta", NULL);
   babl_component_new ("key",     NULL);
-}
 
-static void
-models (void)
-{
   babl_model_new (
     "name", "CMYK",
     babl_component ("cyan"),
@@ -59,6 +54,58 @@ models (void)
     babl_component ("key"),
     NULL
   );
+
+  babl_model_new (
+    "name", "CMYKA",
+    babl_component ("cyan"),
+    babl_component ("magenta"),
+    babl_component ("yellow"),
+    babl_component ("key"),
+    babl_component ("A"),
+    NULL
+  );
+
+  babl_conversion_new (
+    babl_model ("RGBA"),
+    babl_model ("CMYK"),
+    "planar",      rgb_to_cmyk,
+    NULL
+  );
+
+  babl_conversion_new (
+    babl_model ("CMYK"),
+    babl_model ("RGBA"),
+    "planar",      cmyk_to_rgb,
+    NULL
+  );
+
+
+  babl_conversion_new (
+    babl_model ("RGBA"),
+    babl_model ("CMYKA"),
+    "planar",      rgb_to_cmyk,
+    NULL
+  );
+
+  babl_conversion_new (
+    babl_model ("CMYKA"),
+    babl_model ("RGBA"),
+    "planar",      cmyk_to_rgb,
+    NULL
+  );
+
+  babl_format_new (
+      "name",        "CMYK float",
+      babl_model     ("CMYK"),
+      babl_type      ("float"),
+      babl_component ("cyan"),
+      babl_component ("yellow"),
+      babl_component ("magenta"),
+      babl_component ("key"),
+      NULL
+  );
+
+  return 0;
 }
 
 static void
@@ -80,7 +127,7 @@ rgb_to_cmyk (int    src_bands,
 
       double cyan, magenta, yellow, key;
 
-      double pullout = 1.0;
+      double pullout = 0.8;
 
       cyan    = 1.0 - red;
       magenta = 1.0 - green;
@@ -132,8 +179,8 @@ cmyk_to_rgb (int    src_bands,
   while (n--)
     {
       double cyan    = *(double*)src[0];
-      double yellow  = *(double*)src[1];
-      double magenta = *(double*)src[2];
+      double magenta = *(double*)src[1];
+      double yellow  = *(double*)src[2];
       double key     = *(double*)src[3];
 
       double red, green, blue;
@@ -164,36 +211,3 @@ cmyk_to_rgb (int    src_bands,
     }
 }
 
-static void
-conversions (void)
-{
-  babl_conversion_new (
-    babl_model ("RGBA"),
-    babl_model ("CMYK"),
-    "planar",      rgb_to_cmyk,
-    NULL
-  );
-
-
-  babl_conversion_new (
-    babl_model ("CMYK"),
-    babl_model ("RGBA"),
-    "planar",      cmyk_to_rgb,
-    NULL
-  );
-}
-
-static void
-formats (void)
-{
-  babl_format_new (
-      "name",        "CMYK float",
-      babl_model     ("CMYK"),
-      babl_type      ("float"),
-      babl_component ("cyan"),
-      babl_component ("yellow"),
-      babl_component ("magenta"),
-      babl_component ("key"),
-      NULL
-  );
-}